#pragma once
#ifndef SYPX_SINGLETON
#define SYPX_SINGLETON

#include <assert.h>
#include "Base.h"

namespace SypX
{
	template <class T>
	class Singleton
	{
	public:
		static void create()
		{
			if(!obj)
			{
				obj = new T();
			}
		}
		static void destroy()
		{
			if(obj)
			{
				delete obj;
			}
		}
		static T* getSingleton()
		{
			assert(obj && "getSingleton() called before Singleton creation");
			return obj;
		}
	protected:
		static T* obj;

	};

	template <class T>
	T* Singleton<T>::obj = 0;


}

#endif